package com.example.jopewars;

import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import javax.swing.JTextArea;
import java.awt.BorderLayout;

public class ActivityPanel extends JPanel implements GameStateChangedListener {

	private static final long serialVersionUID = 1L;
	private GameEngine game;
	private JTextArea activityTextArea;

	public ActivityPanel() {
		game = GameEngine.getInstance();
		initialize();
	}

	private void initialize() {
		setBorder(new TitledBorder(null, "Activity", TitledBorder.LEADING,
				TitledBorder.TOP, null, null));
		setLayout(new BorderLayout(0, 0));

		activityTextArea = new JTextArea();
		add(activityTextArea);
	}

	public void startGame() {
		String start = "Starting new game...";
		activityTextArea.append(start);
	}

	@Override
	public void gameStateChanged() {
		int turnNumber = game.getTurnNumber();
		String status = "\nTurn: " + turnNumber + " Location: "
				+ game.getLocation().getName();

		activityTextArea.append(status);

	}
}
